import url from '@/tool/index.js'
//预约订单
export const order = (status = 0,page=1) => { //
	return new Promise(resolve => {
		uni.request({
			url: url + '/api/user.practiceorder/lists',
			data: {
				statustype: status,
				page:page,
				token: uni.getStorageSync('userToken')
			},
			header:{
				'Content-Type':'application/x-www-form-urlencoded'
			},
			method: 'POST',
			success: (res) => resolve(res.data),
		});
	})
}
//订单详情
export const testOrderDetail = (orderid) => { //
	return new Promise(resolve => {
		uni.request({
			url: url + '/api/user.practiceorder/detail',
			data: {
				orderid: orderid,
				token: uni.getStorageSync('userToken')
			},
			header:{
				'Content-Type':'application/x-www-form-urlencoded'
			},
			method: 'POST',
			success: (res) => resolve(res.data),
		});
	})
}
//核销二维码
export const hxerweima = (orderid) => { //
	return new Promise(resolve => {
		uni.request({
			url: url + '/api/user.practiceorder/hxerweima',
			data: {
				orderid: orderid,
				token: uni.getStorageSync('userToken')
			},
			header:{
				'Content-Type':'application/x-www-form-urlencoded'
			},
			method: 'POST',
			success: (res) => resolve(res.data),
		});
	})
}

//评价订单
export const comment = (orderid, star, content,cartype=1) => { //
	return new Promise(resolve => {
		uni.request({
			url: url + '/api/user.order/comment',
			data: {
				orderid: orderid,
				star: star,
				content: content,
				cartype:cartype,
				token: uni.getStorageSync('userToken')
			},
			header:{
				'Content-Type':'application/x-www-form-urlencoded'
			},
			method: 'POST',
			success: (res) => resolve(res.data),
		});
	})
}

//取消订单
export const cancelorder = (ordernumber) => { //
	return new Promise(resolve => {
		uni.request({
			url: url + '/api/user.practiceorder/cancelorder',
			data: {
				ordernumber: ordernumber,
				token: uni.getStorageSync('userToken')
			},
			header:{
				'Content-Type':'application/x-www-form-urlencoded'
			},
			method: 'POST',
			success: (res) => resolve(res.data),
		});
	})
}

//申请退款
export const refundorder = (ordernumber) => { //
	return new Promise(resolve => {
		uni.request({
			url: url + '/api/user.practiceorder/refundorder',
			data: {
				ordernumber: ordernumber,
				token: uni.getStorageSync('userToken')
			},
			header:{
				'Content-Type':'application/x-www-form-urlencoded'
			},
			method: 'POST',
			success: (res) => resolve(res.data),
		});
	})
}

//删除订单
export const delorder = (order_number) => { //
	return new Promise(resolve => {
		uni.request({
			url: url + '/api/user.practiceorder/delorder',
			data: {
				ordernumber: order_number,
				token: uni.getStorageSync('userToken')
			},
			header:{
				'Content-Type':'application/x-www-form-urlencoded'
			},
			method: 'POST',
			success: (res) => resolve(res.data),
		});
	})
}
